package com.lzs.chuku.service.impl;

import com.lzs.entity.Otherout;
import com.lzs.chuku.mapper.OtheroutMapper;
import com.lzs.chuku.service.OtheroutService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lzs.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 刘中帅
 * @since 2020-11-23
 */
@Service
public class OtheroutServiceImpl extends ServiceImpl<OtheroutMapper, Otherout> implements OtheroutService {

    @Autowired
    private OtheroutMapper otheroutMapper;
    @Override
    public R changeState(List<Long> otheroutids, String s) {
        try {
            for (int i = 0; i < otheroutids.size(); i++) {
                Otherout otherout = otheroutMapper.selectById(otheroutids.get(i));
                if (otherout.getState().equals("1")) {
                    return R.error().message("其中已经存在已审核的条目");
                }
            }
            otheroutMapper.changeState(otheroutids, s);
        }catch (Exception e){
            return R.error().message("审核失败");
        }
        return null;
    }
}
